<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\library\Ems;
use app\common\library\Sms;
use fast\Random;
use think\Config;
use think\Validate;

/**
 * 投诉建议接口
 */
class Complaint extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['createcomplaint'];

    public function _initialize()
    {
        parent::_initialize();

        if (!Config::get('fastadmin.usercenter')) {
            $this->error(__('User center already closed'));
        }
        $this->complainttype=model('admin/complaint/Type');
        $this->complaintcomplaints=model('admin/complaint/Complaints');
    }


    /**
     * 投诉建议类型
     */
    public function complainttype(){
        $this->success('OK',$this->complainttype->order('weigh desc')->select());


    }

    /**
     * 提交投诉建议
     * @param $type
     * @param $content
     * @param null $images
     */
    public  function createcomplaint($type,$content,$images=null){

        $this->complaintcomplaints::Create(['userid'=>$this->auth->id,'complaint_type_id'=>$type,'content'=>$content,'images'=>$images]);
        $this->success('提交成功，等待管理员回复');
    }




}
